import request from '@/utils/request'

export default {

  /*
  查找一级分类列表
  */
  getCategorys1() {
    /* return request({
      url: '/admin/product/getCategory1',
      method: 'get'
    }) */
    // 修改为request.xxx()
    return request.get('/admin/product/getCategory1')
  },

  /*
  查找二级分类列表
  */
  getCategorys2(category1Id) {
    /* return request({
      url: '/admin/product/getCategory2/' + category1Id,
      method: 'get'
    }) */
    return request.get('/admin/product/getCategory2/' + category1Id)
  },

  /*
  查找三级分类列表
  */
  getCategorys3(category2Id) {
    /* return request({
      url: '/admin/product/getCategory3/' + category2Id,
      method: 'get'
    }) */
    return request.get('/admin/product/getCategory3/' + category2Id)
  },
  addCategory1(value) {
    return request({
      url:'/admin/product/saveCategory1',
      method: 'post',
      data:{
        name: value
      }
    })
  },
  delCategory(row) {
    let level = row.level ? row.level : '3';
    return request.delete(`/admin/product/removeCategory${level}/${row.id}`)
  },
  addCategory2(name, id){
    return request({
      url:'/admin/product/saveCategory2',
      method: 'post',
      data:{
        catgory1Id:id,
        name: value
      }
    })
  },
  addCategory3(name, id){
    return request({
      url:'/admin/product/saveCategory2',
      method: 'post',
      data:{
        catgory2Id:id,
        name: value
      }
    })
  },
  editCategory1(id, name){
    return request({
      url : '/admin/product/updateeCategory1',
      method: 'put',
      data: {
        name
      }
    })
  },
  editCategory2(parentid, id, name){
    return request({
      url : '/admin/product/updateeCategory2',
      method: 'put',
      data: {
        category1Id:parentid,
        id,
        name
      }
    })
  },
  editCategory3(parentid, id, name){
    return request({
      url : '/admin/product/updateeCategory3',
      method: 'put',
      data: {
        category2Id:parentid,
        id,
        name
      }
    })
  }

}
